home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / snip9_91.arc / LITECLAS.CPP < prev    next >
C/C++ Source or Header  |  1991-09-17  |  2KB  |  43 lines

  1. class SerialPort
  2.   {
  3.       Word B;  // bps 1200, 2400, 4800 or 9600
  4.       Word IBS; // input buffer size
  5.       Word OBS; // output buffer size
  6.       Byte P;  // the port num 1, 2, 3 or 4
  7.       Byte Pa; // the parity (NoParity, OddParity, etc.)
  8.       Byte DB; // data bits
  9.       Byte SB; // stop bits
  10.       void Reset(){comm_setup(P,B,Pa,DB,SB);}
  11.     public:
  12.       SerialPort(Byte PortNum,Word BPS,
  13.           Word MaxInBuffSize=256,Word MaxOutBuffSize=256,
  14.           Byte Parity=NoParity,Byte DataBits=DataBit8,Byte StopBits=StopBit1);
  15.       ~SerialPort(){Close();}
  16.       void Close(){comm_close(P,False);}
  17.       Byte PortNum(){return P;}
  18.       Word BPS(){return B;}
  19.       Word MaxInBuffSize(){return IBS;}
  20.       Word InBuffSize(){return lc_icnt(P);}
  21.       Word MaxOutBuffSize(){return OBS;}
  22.       Word OutBuffSize(){return lc_ocnt(P);}
  23.       Byte Parity(){return Pa;}
  24.       Byte DataBits(){return DB;}
  25.       Byte StopBits(){return SB;}
  26.       void ResetBPS(Word BPS){B=BPS; Reset();}
  27.       void ResetParity(Byte Parity){Pa=Parity; Reset();}
  28.       void ResetDataBits(Byte DataBits){DB=DataBits; Reset();}
  29.       void ResetStopBits(Byte StopBits){SB=StopBits; Reset();}
  30.       Char Peek(){return Char(lc_peek(P));}
  31.       Char Read(){return Char(lc_getw(P));}  // will wait for char
  32.       void Send(Char C){lc_put(P,C);}
  33.       void Send(const Char* CS){lc_puts(P,CS,strlen(CS));}
  34.       void FlushOutBuff(){lc_tflush(P);}
  35.       void FlushInBuff(){lc_rflush(P);}
  36.       Bool CarrierDetect(){return ((lc_mstat(P)&DCD)!=0);}
  37.   };
  38. /* 
  39. For the untrained eye:  Bool, Byte, Char and Word are derived types using
  40. "typedef" (unsigned char, unsigned char, unsigned char and unsigned short
  41. respectively).
  42. */
  43.